package com.busi.wms.controller;

import java.util.List;

import com.busi.wms.model.WmsMaterial;
import com.jfinal.plugin.activerecord.Record;
import com.zcurd.common.tool.DBTool;
import com.zcurd.common.util.StringUtil;
import com.zcurd.controller.BaseController;

/**
 * 首页综合查询
 */
public class MainQueryController extends BaseController {
	
	//首页图表
	public void canvasPage(){
		render("storage_Report.html");
	}
	
	public void listPage() {
		setAttr("dictDataOfStorage", WmsMaterial.me.getDictDataOfstorage());
		setAttr("dictDataCate_name", WmsMaterial.me.getDictDatacate_name());
		render("list.html");
	}
	
	public void listData() {
		Object[] queryParams = getQueryParams();
		String[] properties = (String[]) queryParams[0];
		String[] symbols = (String[]) queryParams[1];
		Object[] values = (Object[]) queryParams[2];
		
		String orderBy = getOrderBy();
		if(StringUtil.isEmpty(orderBy)) {
			orderBy = "mat_no desc";
		}
		
		List<Record> list = DBTool.findByMultProperties("wms_mat_query_v", properties, symbols, values, orderBy, getPager());
//		Map<String, Object> dictDatacate_no = WmsMaterial.me.getDictDatacate_no();		
//		for(Record record : list) {
//			String fieldName = "cate_name";
//			if(dictDatacate_no.get(record.get(fieldName).toString()) != null) {
//				record.set(fieldName, dictDatacate_no.get(record.get(fieldName).toString()));
//			}			
//		}		
		renderDatagrid(
			list, 
			DBTool.countByMultProperties("wms_mat_query_v", properties, symbols, values)
		);	
	}		
}
